package org.tank;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List;

public class Tank extends Frame {
    int x=200;
    int y=200;
    int width=50;
    int height=50;
    TankFram2 fram2=null;
    //坦克的移动速度
    public static  final int  speed=1;
    //判断坦克是否活着
    boolean isLive=true;

    public Tank(int x, int y,TankFram2 fram2,boolean islive,int width,int height) {
        this.x = x;
        this.y = y;
        this.fram2=fram2;
        this.isLive=islive;
        this.width=width;
        this.height=height;
    }

    public Tank(){}

    public void fillRect(Graphics g,Boolean left ,Boolean right ,
                         Boolean up ,Boolean down ,Color color,int width,int height) {
//      if(left) g.drawImage(TankImage.tankL,x,y,null);
//        if(right) g.drawImage(TankImage.tankR,x,y,null);
//        if(up) g.drawImage(TankImage.tankU,x,y,null);
//        if(down) g.drawImage(TankImage.tankD,x,y,null);


      if(color==null) {
          g.setColor(Color.blue);
      }

        g.setColor(color);
        g.fillRect(x,y,width,height);
    }

    public void setMove(boolean isLeft,boolean isRight,boolean isUp,boolean isDown) {

        if(isLeft) x-=speed;
        if(isRight) x+=speed;
        if(isUp) y-=speed;
        if(isDown) y+=speed;
    }

    /**
     * 开火 渲染出来子弹
     * @param isLeft
     * @param isRight
     * @param isUp
     * @param isDown
     */
    public void setFire(boolean isLeft, boolean isRight, boolean isUp, boolean isDown,TankFram2 tankFram2) {
        System.out.println("开火");
        fram2.list.add(new Bullet(this.x + 20, this.y - 20, 50, 50,tankFram2));
    }

    public static void main(String[] args) {
        BufferedImage tankL = TankImage.tankD;
        System.out.println(tankL);
    }


}
